@extends('common.base-master')

@section('html-head')
    <link rel="stylesheet" href="{{url('css/style.css')}}">
    <link rel="stylesheet" href="{{url('css/common.css')}}">
    <link rel="stylesheet" href="{{url('css/public.css')}}">
    <style>
        body{
            background-color: #f3f3f3;
        }
        .title{text-align: center;margin-top: 2rem;color: #5f6363;font-size: 1.0rem;font-family: '黑体';}
        .weibo{margin-top: 3rem;text-align: center}
        .weibo span{display: block;color: #c6cac9}
        .weibo img{margin-top: 1rem}
        .hidden{display: none}
    </style>
@endsection

@section('html-body')
    <div>
        <div class="title">吉日居酒屋优惠券核销</div>
        <div class="weui-cells">
            <div class="weui-cell weui-cell_vcode right_15--before" style="height: 60px">
                <div class="weui-cell__hd">
                    <div class="weui-label input-label">兑换券码：</div>
                </div>
                <div class="weui-cell__bd" style="height: 60px;line-height: 60px">
                    <input type="tel" name="newphone" class="weui-input" id="phone" placeholder="请输入兑换券6位密码">
                </div>
            </div>
        </div>
        <!-- 按钮 -->
        <div class="demos-content-padded margin-t_20" style="margin-top: 30px">
            <a href="javascript:void(0);" class="weui-btn bg-color__theme font-color_white bg-color__theme--active" id="btn_login" style="border: none;width: 96%;background-color: #1cac1b;">核销</a>
        </div>
    </div>
    <script>
        $(function () {

            $('#btn_login').click(function () {
                var phone = $('#phone').val();

                $.ajax({
                    url:"{{route('Api.Wechat.checkCode')}}",
                    type:'post',
                    dataType:'json',
                    data:{code:phone},
                    success:function (obj) {
                        if(obj.level == 'success'){
                            $.alert(obj.message, '<span style="color:green">兑换成功！</span>');
                        }else {
                            $.alert(obj.message, '<span style="color:red">兑换失败！</span>');
                        }
                    },
                    error:function (obj) {

                    }
                });
            });

            function is_weixn(){
                var ua = navigator.userAgent.toLowerCase();
                if(ua.match(/MicroMessenger/i)=="micromessenger") {
                    return true;
                } else {
                    return false;
                }
            }
        });
    </script>
@endsection